import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
  IsArray,
  IsDate,
  IsInt,
  IsNumber,
  IsString,
  ValidateNested,
} from 'class-validator';

export class CreateGoodsDto {
  @ApiProperty({
    example: 'RTX3060',
    required: true,
  })
  @IsString()
  readonly skuName: string;

  @ApiProperty({
    example: '1234567',
    required: true,
  })
  @IsString()
  readonly skuId: string;

  @ApiProperty({
    example: 'qicaihong',
    required: true,
  })
  @IsString()
  readonly shopName: string;

  @ApiProperty({
    example: 123.4,
    required: true,
  })
  @IsNumber()
  @Type(() => Number)
  readonly shopPrice: number;

  @ApiProperty({
    example: 124.3,
    required: true,
  })
  @IsNumber()
  @Type(() => Number)
  readonly platformPrice: number;

  @ApiProperty({ example: 'shangmingp:faf sku:123...', required: true })
  @IsString()
  readonly detail: string;

  @ApiProperty({ example: 'jd', required: true })
  @IsString()
  readonly source: string;

  @ApiProperty({ example: '1', required: true })
  @IsInt()
  @Type(() => Number)
  readonly taskId: number;

  @ApiProperty({ example: `${new Date()}`, required: true })
  @IsDate()
  @Type(() => Date)
  readonly updateTime: Date;
}
export class CreateManyGoodsDto {
  @ApiProperty({
    description: 'Array of goods to create',
    type: [CreateGoodsDto], // Specifies that this is an array of CreateGoodsDto
  })
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => CreateGoodsDto)
  data: CreateGoodsDto[];
}
